   /*-------------- Canvas framework ---------------*/
   /*   Document   : tester.js
    *   Created on : 24-jul-2013
    *   Author     : Blue king
    *   Description: Initiation on HTML5 canvas using easelJS
    */
    var stage;
    var ball, ballx, bally, ball2x, ball2y, x, y, pointerX, pointerY;
    var pointer;

    function init2(){
           stage = new createjs.Stage("canvas");
           pointer = new createjs.Bitmap("2_1_1.png");
           pointer2 = new createjs.Bitmap("2_1_2.png");
           
           ball = new createjs.Shape();
           ball2 = new createjs.Shape();
           ball3 = new createjs.Shape();
           
           ball.graphics.beginFill("#FE2E2E").drawCircle(0,0,50);
           ball2.graphics.beginFill("#FE2E2E").drawCircle(0,0,50);
           ball3.graphics.beginFill("#FE2E2E").drawCircle(0,0,50);
           ball.x = 50;
           ball.y = 100;
           ball2.x = 50;
           ball2.y = 100;
           ball3.x = 50;
           ball3.y = 100;
           
           ball.alpha = 0.5;
           ball2.alpha = 0.4;
           ball3.alpha = 0.3;
           
           createjs.Ticker.addEventListener("tick", tick5);
           createjs.Ticker.addEventListener("tick", tick2);
           createjs.Ticker.addEventListener("tick", tick3);
           createjs.Ticker.addEventListener("tick", tick4);
           
           pointerX = pointer.x;
           pointerY = pointer.y;
           
           stage.addChild(pointer);
           //stage.addChild(ball3);
           //stage.addChild(ball2);
           //stage.addChild(ball);
       }
       
    var move = "right";
    
 
function get_random_color() {
    var letters = '0123456789ABCDEF'.split('');
    var color = '#';
    for (var i = 0; i < 6; i++ ) {
        color += letters[Math.round(Math.random() * 15)];
    }
    return color;
}
     
function tick5(){
    ball.x = stage.mouseX;
    ball.y = stage.mouseY;
   
    stage.update();
}

function tick2(){
        ball2.x = ballx;
        ball2.y = bally;
        ballx = ball.x;
        bally = ball.y;
    

}

function tick3(){
        ball3.x = ball2x;
        ball3.y = ball2y;
        ball2x = ball2.x;
        ball2y = ball2.y;
    

}

function tick4(){
    
    if((stage.mouseX < pointer.x+50) && !(stage.mouseX > pointer.x+40)){
        pointerX = pointerX-10;
        if(!(stage.getChildByName(pointer) === pointer)){
            stage.removeChild(pointer2);
            stage.addChild(pointer);
        }
    }
    if((stage.mouseY < pointer.y+50) && !(stage.mouseY > pointer.y+40)){
        pointerY = pointerY-10;
    }
    if((stage.mouseX > pointer.x+50) && !(stage.mouseX < pointer.x+60)){
        pointerX += 10;
        if(!(stage.getChildByName(pointer2) === pointer2)){
            stage.removeChild(pointer);
            stage.addChild(pointer2);
        }
    }
    if((stage.mouseY > pointer.y+50) && !(stage.mouseY < pointer.y+60)){
        pointerY += 10;
    }


pointer.x = pointerX;
pointer2.x = pointerX;

pointer.y = pointerY;
pointer2.y = pointerY;
}
